/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControleAcademico.Model.Dao;

import ControleAcademico.Model.Pojo.Aluno;
import ControleAcademico.Model.Pojo.Turma;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.NoResultException;

/**
 *
 * @author arthur
 * @author renan
 * @author tais
 * @author vinicius
 */
public class PersisteTurmaImp extends DaoBase<Turma> implements PersisteTurma{

    @Override
    public List<Turma> retornarTodos(){
        try {
            return findAll();
        } catch (Exception ex) {
            return new ArrayList<Turma>();
        }
    }
    
    @Override
    public boolean salvar(Turma turma){
        if(save(turma)){
            return true;
        }else{
            return false;
        }
    }
    
    @Override
    public void atualizar(Turma turma){
        update(turma);
    }
    
    @Override
    public Turma retornarPeloId(int id){
        try{
            return getEntityManager().find(Turma.class, id);
        }catch(NoResultException ex){
            return null;
        }
            
    }
    
     @Override
    public boolean deletar(Turma turma) {
        if(delete(turma)) {
            return true;
        } else {
            return false;
        }
    }
    
}
